import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.util.ArrayList;
import java.util.List;


public class GroupOfBuildings implements GameObject{
	
	static List<Building> bldgs = new ArrayList<Building>();
	boolean m1 = false;
	boolean m2 = false;
	
	GroupOfBuildings(){
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		

		if(arg0.getY() >= 815 && arg0.getY() <= 915 && arg0.getX() >= 675 && arg0.getX() <= 775 && m1 == false){
			m1 = true;
			bldgs.add(new Barracks(arg0.getX(), arg0.getY()));
			System.out.println("+1");
		}
		else if(m1 == true){
			m2 = true;
			m1 = false;
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {

	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {

		for(Building b: bldgs){
			b.setX(arg0.getX());
			b.setY(arg0.getY());
		}
		
	}

	@Override
	public void mouseWheelMoved(MouseWheelEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Shape getShape() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Color getColor() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public double getX() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public double getY() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public void paint(Graphics2D g){
		
		for(Building b: bldgs){
			b.paint(g);
		}
	}
	
	public void add(Building b){
		bldgs.add(b);
	}
}
